﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="OnlineRequestSlipEdit.aspx.cs"
    Inherits="Main_Inventory_OnlineRequestSlipEdit" Culture="en-GB" %>

<%@ Register Src="~/User Controls/PageHeading.ascx" TagName="heading" TagPrefix="acc" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="Ajax" %>
<%@ Register Assembly="CalendarExtenderPlus" Namespace="AjaxControlToolkitPlus" TagPrefix="advancedCalender" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script src="../../JavaScript/Commons.js" type="text/javascript"></script>
    <link href="../../Styles/accounts.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
        .AutoExtender
        {
            margin: 0px;
            background-color: White;
            color: windowtext;
            border: 1px solid #006699;
            line-height: 18px;
            padding: 8px;
            border-width: 1px;
            border-style: solid;
            cursor: 'default';
            height: auto;
            min-height: 10px;
            font-family: Verdana, Helvetica, Sans-Serif;
            font-size: .8em;
            font-weight: normal;
            text-align: left;
            list-style-type: none;
        }
        .AutoExtenderList
        {
            border-bottom: solid 1px #006699;
            color: Maroon;
            padding: 1px;
        }
        .AutoExtenderHighlight
        {
            color: White;
            background-color: #006699;
            padding: 1px;
        }
    </style>
    <script type="text/javascript">
        function CheckRowForOnlineRequestSlip() {
            var countrow = document.getElementById("idvalue").value;
            for (var i = 1; i <= countrow; i++) {
                var ItemCode = document.getElementById("txtitemcode" + i).value;
                var Qty = document.getElementById("txtqty" + i).value;
                var pecode = document.getElementById("txtpecode" + i).value;
                var ro = document.getElementById("txtro" + i).value;
                var customer = document.getElementById("ddlcustomer" + i).value;
                var projectname = document.getElementById("ddlprojectname" + i).value;
                if (ItemCode != '' || Qty != '' || pecode != '' || ro != '' || customer != 0 || projectname != 0) {
                    if (ItemCode == '') {
                        alert("Please Enter Item Code for [" + i + "] Row");
                        document.getElementById("txtitemcode" + i).focus();
                        return false;
                    }
                    else if (Qty == '') {
                        alert("Please Enter Qty for [" + i + "] Row");
                        document.getElementById("txtqty" + i).focus();
                        return false;
                    }
                    else if (pecode == '') {
                        alert("Please Enter PECode for [" + i + "] Row");
                        document.getElementById("txtpecode" + i).focus();
                        return false;
                    }
                    else if (ro == '') {
                        alert("Please Enter RO# for [" + i + "] Row");
                        document.getElementById("txtro" + i).focus();
                        return false;
                    }
                    else if (customer == 0) {
                        alert("Please Select Customer for [" + i + "] Row");
                        document.getElementById("ddlcustomer" + i).focus();
                        return false;
                    }
                    else if (projectname == 0) {
                        alert("Please Select Project Name for [" + i + "] Row");
                        document.getElementById("ddlprojectname" + i).focus();
                        return false;
                    }
                }
                else {
                    alert("Insert SuccessFully");
                }
            }
        }
        function validitemcode() {
            var count = document.getElementById("idvalue").value;
            for (var i = 1; i <= count; i++) {
                var ItemCode = document.getElementById("txtitemcode" + i).value
                if (ItemCode == '')// || Qty != '' || pecode != '' || ro != ''|| customer != 0 || projectname != 0) 
                {
                    alert("Enter Valid Item Code For [" + i + "] Row.");
                    document.getElementById("txtitemcode" + i).focus();
                    return false;
                }
            }
        }
        function validPECode() {
            var count = document.getElementById("idvalue").value;
            for (var i = 1; i <= count; i++) {
                var ItemCode = document.getElementById("txtpecode" + i).value
                if (ItemCode == '')// || Qty != '' || pecode != '' || ro != ''|| customer != 0 || projectname != 0) 
                {
                    alert("Enter Valid PECode For [" + i + "] Row.");
                    document.getElementById("txtpecode" + i).focus();
                    return false;
                }
            }
        }
        function rowEmpty() {
            var count = document.getElementById("idvalue").value;
            for (var i = 1; i <= count; i++) {
                var ItemCode = document.getElementById("txtitemcode" + i).value;
                var Qty = document.getElementById("txtqty" + i).value;
                var pecode = document.getElementById("txtpecode" + i).value;
                var ro = document.getElementById("txtro" + i).value;
                var customer = document.getElementById("ddlcustomer" + i).value;
                var projectname = document.getElementById("ddlprojectname" + i).value;
                if (i == 1) {
                    if (ItemCode == '' || Qty == '' || pecode == '' || ro == '' || customer == 0 || projectname == 0) {
                        alert("Enter Request Slip Details.");
                        return false;
                    }
                    if (ItemCode != '' || Qty != '' || pecode != '' || ro != '' || customer != 0 || projectname != 0) {
                        //CheckRowForOnlineRequestSlip();
                        document.getElementById("txtitemcode" + i).value = '';
                        document.getElementById("txtqty" + i).value = '';
                        document.getElementById("txtpecode" + i).value = '';
                        document.getElementById("txtro" + i).value = '';
                        document.getElementById("txtitemdesc" + i).value = ''
                        document.getElementById("txtproductmodel" + i).value = ''
                        document.getElementById("txtproductdesc" + i).value = ''
                        document.getElementById("ddlcustomer" + i).value = 0;
                        document.getElementById("ddlprojectname" + i).value = 0;

                    }
                }
                else {
                    if (ItemCode != '' || Qty != '' || pecode != '' || ro != '' || customer != 0 || projectname != 0) {
                        //CheckRowForOnlineRequestSlip();
                        document.getElementById("txtitemcode" + i).value = '';
                        document.getElementById("txtqty" + i).value = '';
                        document.getElementById("txtpecode" + i).value = '';
                        document.getElementById("txtro" + i).value = '';
                        document.getElementById("txtitemdesc" + i).value = ''
                        document.getElementById("txtproductmodel" + i).value = ''
                        document.getElementById("txtproductdesc" + i).value = ''
                        document.getElementById("ddlcustomer" + i).value = 0;
                        document.getElementById("ddlprojectname" + i).value = 0;
                    }
                }
            }
            alert("Inserted SuccessFully.");
        }
        function isNumberKey(control_id, evt) {
            var charCode = (evt.which) ? evt.which : event.keyCode
            if (charCode > 31 && (charCode < 48 || charCode > 57) && (charCode < 45 || charCode > 47))
                return false;

            if (charCode == 46) {
                var dotcount = document.getElementById(control_id).value.split('.').length - 1;
                if (dotcount >= 1) {
                    return false;
                }
            }
            return true;
        }
        function CatchTab(myfield, e) {//disable keydown event of textbox not TAB key
            var keycode;
            if (window.event) {
                keycode = window.event.keyCode;
            }
            else if (e) {
                keycode = e.which;
            }
            else {
                return true;
            }

            if (keycode == 9) {
                // if is the tab key
                return true;
            }
            else {
                return false;
            }
        }     
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="scriptmgr" EnablePageMethods="true" EnablePartialRendering="true"
        runat="server">
    </asp:ScriptManager>
    <asp:Panel ID="pnlonlinedetail" runat="server">
        <acc:heading ID="header1" runat="server" HeadingText="Edit Online Request Slip" />
        <div align="center">
            <asp:Label ID="lblmsg" runat="server"></asp:Label>
        </div>
        <div align="center">
            <table class="tablecontent" width="50%">
                <tr>
                    <td class="headtd" colspan="6">
                        Registration Slip
                    </td>
                </tr>
                <tr>
                    <td>
                    </td>
                    <td>
                        Request Date
                    </td>
                    <td>
                        <asp:TextBox ID="txtreqdate" runat="server" ForeColor="Black" CssClass="inputnumber"
                            onkeydown="return CatchTab(this.id,event)" Style="background-color: LightGray;
                            text-align: left;"></asp:TextBox>
                        <asp:ImageButton ID="btnDate" runat="server" ImageUrl="~/Images/calendar.gif" />
                        <%--  <advancedCalender:CalendarExtenderPlus ID="CalFrom" runat="server" PopupButtonID="btnDate"
                            Format="dd/MM/yyyy" TargetControlID="txtreqdate">
                        </advancedCalender:CalendarExtenderPlus>--%>
                        <Ajax:CalendarExtender ID="Calform" runat="server" PopupButtonID="btnDate" Format="dd/MM/yyyy"
                            TargetControlID="txtreqdate">
                        </Ajax:CalendarExtender>
                    </td>
                    <td>
                        Slip No
                    </td>
                    <td>
                        <asp:TextBox ID="txtslipno" runat="server" CssClass="input" Enabled="false" ForeColor="Black"></asp:TextBox>
                        <asp:HiddenField ID="hidregid" runat="server" />
                    </td>
                    <td>
                    </td>
                </tr>
                <tr>
                    <td>
                    </td>
                    <td>
                        User Name
                    </td>
                    <td>
                        <asp:TextBox ID="txtusername" runat="server" CssClass="input" Enabled="false" ForeColor="Black"></asp:TextBox>
                    </td>
                    <td>
                        Remarks
                    </td>
                    <td>
                        <asp:TextBox ID="txtremarks" runat="server" CssClass="inputnumber" Style="text-align: left;"></asp:TextBox>
                    </td>
                    <td>
                    </td>
                </tr>
            </table>
        </div>
        <asp:UpdatePanel ID="updatepanel" runat="server">
            <ContentTemplate>
                <div align="center" style="margin-top: 20px;">
                    <div style="overflow: auto; border: 1px solid #818181; height: 260px; width: 90%;">
                        <asp:HiddenField ID="idvalue" runat="server" Value="3" />
                        <table id="tblOnlineRequestSlip" runat="server" cellpadding="2" cellspacing="0" style="border: 1px solid #818181;">
                            <tr style="color: Black; font-size: 11px; font-family: Verdana; font-weight: bold;">
                                <td style="border-right: 1px solid #818181; border-bottom: 1px solid #818181; text-align: center;
                                    font-weight: bold; width: 10%;">
                                    Item Code
                                </td>
                                <td style="border-right: 1px solid #818181; border-bottom: 1px solid #818181; text-align: center;
                                    font-weight: bold; width: 10%;">
                                    Item Desc
                                </td>
                                <td style="border-right: 1px solid #818181; border-bottom: 1px solid #818181; text-align: center;
                                    font-weight: bold; width: 8%;">
                                    Available Qty
                                </td>
                                <td style="border-right: 1px solid #818181; border-bottom: 1px solid #818181; text-align: center;
                                    font-weight: bold; width: 10%;">
                                    Qty
                                    <script type="text/javascript">
                                        function checkqty() {
                                            var flag = true;
                                            var Count = document.getElementById("idvalue").value;
                                            for (var i = 1; i <= Count; i++) {
                                                var qty = document.getElementById("txtqty" + i).value;
                                                var hidqty = document.getElementById("lblTotalqty" + i).innerHTML;
                                                if (parseInt(qty) > parseInt(hidqty)) {
                                                    alert("Your Balance Quantity for this item is:- " + parseFloat(hidqty).toFixed(0));
                                                    document.getElementById("txtqty" + i).value = "";
                                                    document.getElementById("txtqty" + i).focus(); flag = false;
                                                    break;
                                                }
                                                flag = true;
                                            }

                                        }
                                    </script>
                                </td>
                                <td style="border-right: 1px solid #818181; border-bottom: 1px solid #818181; text-align: center;
                                    font-weight: bold; width: 10%;">
                                    <asp:Label ID="Label1" runat="server" Text="PE Code" ToolTip="Pre Engineering Code."
                                        Width="96%"></asp:Label>
                                </td>
                                <td style="border-right: 1px solid #818181; border-bottom: 1px solid #818181; text-align: center;
                                    font-weight: bold; width: 10%;">
                                    Product Desc
                                </td>
                                <td style="border-right: 1px solid #818181; border-bottom: 1px solid #818181; text-align: center;
                                    font-weight: bold; width: 10%;">
                                    Product Model
                                </td>
                                <td style="border-right: 1px solid #818181; border-bottom: 1px solid #818181; text-align: center;
                                    font-weight: bold; width: 10%;">
                                    <asp:Label ID="lblro" runat="server" Text="RO#" ToolTip="Repair Order No." Width="96%"></asp:Label>
                                </td>
                                <td style="border-right: 1px solid #818181; border-bottom: 1px solid #818181; text-align: center;
                                    font-weight: bold; width: 10%;">
                                    Customer
                                </td>
                                <td style="border-right: 1px solid #818181; border-bottom: 1px solid #818181; text-align: center;
                                    font-weight: bold; width: 10%;">
                                    Project Name
                                </td>
                            </tr>
                        </table>
                    </div>
                </div>
            </ContentTemplate>
        </asp:UpdatePanel>
        <table align="center">
            <tr>
                <td>
                    <asp:Button ID="btnSave" runat="server" Text="Update" OnClientClick="return validation();"
                        Width="90px" CssClass="button1" OnClick="btnSave_Click" />
                    <script type="text/javascript">
                        function validation() {
                            if (document.getElementById("txtreqdate").value == '') {
                                alert("Enter Request Date.");
                                document.getElementById("btnDate").focus();
                                return false;
                            }
                        }
                        if (validation() == true) {

                            alert("Request Updated..... ");
                        }
                    </script>
                    <asp:Button ID="btnCancel" runat="server" Text="Cancel" Width="90px" CssClass="button1"
                        OnClick="btnCancel_Click" />
                </td>
            </tr>
        </table>
    </asp:Panel>
    </form>
</body>
</html>
